package com.jianguozh.difs.framework.constant.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.IEnum;
import com.jianguozh.difs.framework.annotation.EnumDesc;

/**
 * 启用、禁用枚举
 * 0,1值
 *
 * @author hanrs
 * @email 4076130@qq.com
 * @since 2022/3/15 15:04
 */
@EnumDesc(title = "状态开启")
public enum OnOffEnum implements IEnum<String> {

    ON("1", "启用"), OFF("0", "禁用");

    private final String value;
    private final String displayName;

    OnOffEnum(String value, String displayName) {
        this.value = value;
        this.displayName = displayName;
    }

    /**
     * 根据名称获取枚举
     *
     * @param value value
     * @return
     */
    public static OnOffEnum fromValue(String value) {
        if (StrUtil.isNotBlank(value)) {
            for (OnOffEnum item : OnOffEnum.values()) {
                if (value.equals(item.getValue())) {
                    return item;
                }
            }
        }
        return null;
    }

    @Override
    public String getValue() {
        return value;
    }

    public String getDisplayName() {
        return displayName;
    }

    @Override
    public String toString() {
        return this.displayName;
    }}
